package com.czl.module_storehouse.mvp.presenter;

import com.czl.base.data.bean.tengyun.ProductBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_base.mvp.presenter.BasePresenter;
import com.czl.module_base.mvp.view.IView;
import com.czl.module_base.observer.AbsHandleSubscriber;
import com.czl.module_storehouse.mvp.model.ProductModel;

/**
 * @author by xubin,
 * @date on 2022/2/11.
 * PS: Not easy to write code, please indicate.
 */
public class ProductPresenter extends BasePresenter<ProductModel, IView> {

    public static final String TAG_PRODUCT_INFO = "product_info";
    public static final String TAG_PRODUCT_INFO_BY_CODE = "product_info_by_code";
    public static final String TAG_PRODUCT_USE_INFO = "product_use_info";
    public static final String TAG_PRODUCT_USE_INFO_BY_CODE = "product_use_info_by_code";

    public void getProductInfo(int productId) {
        doSubscribe2(mModel.getProductInfo(productId), new AbsHandleSubscriber<HttpResponse<ProductBean>>() {
            @Override
            public void onSuccess(HttpResponse<ProductBean> httpResponse) {
                httpResponse.setRequestTag(TAG_PRODUCT_INFO);
                mView.showHttpResponse(httpResponse);
            }
        });
    }

    public void getProductInfoByCode(String productCode) {
        doSubscribe2(mModel.getProductInfoByCode(productCode), new AbsHandleSubscriber<HttpResponse<ProductBean>>() {
            @Override
            public void onSuccess(HttpResponse<ProductBean> httpResponse) {
                httpResponse.setRequestTag(TAG_PRODUCT_INFO_BY_CODE);
                mView.showHttpResponse(httpResponse);
            }
        });
    }

    public void getProductUseInfo(int productId) {
        doSubscribe2(mModel.getProductUseInfo(productId), new AbsHandleSubscriber<HttpResponse<ProductBean>>() {
            @Override
            public void onSuccess(HttpResponse<ProductBean> httpResponse) {
                httpResponse.setRequestTag(TAG_PRODUCT_USE_INFO);
                mView.showHttpResponse(httpResponse);
            }
        });
    }

    public void getProductUseInfoByCode(String productCode) {
        doSubscribe2(mModel.getProductUseInfoByCode(productCode), new AbsHandleSubscriber<HttpResponse<ProductBean>>() {
            @Override
            public void onSuccess(HttpResponse<ProductBean> httpResponse) {
                httpResponse.setRequestTag(TAG_PRODUCT_USE_INFO_BY_CODE);
                mView.showHttpResponse(httpResponse);
            }
        });
    }
}
